﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WF.Model;

namespace WF.Common
{
    public class UserProfile
    {
        private object _lockObject = new object();

        private string _corpName;

        public string CorpName
        {
            get { return _corpName; }
            set { _corpName = value; }
        }

        private string _loginName;

        public string LoginName
        {
            get { return _loginName; }
            set { _loginName = value; }
        }
        private string _empID;

        public string EmpID
        {
            get { return _empID; }
            set { _empID = value; }
        }
        private string _empNo;

        public string EmpNo
        {
            get { return _empNo; }
            set { _empNo = value; }
        }
        private string _empname;

        public string Empname
        {
            get { return _empname; }
            set { _empname = value; }
        }
        private string _deptID;

        public string DeptID
        {
            get { return _deptID; }
            set { _deptID = value; }
        }
        private string _deptName;

        public string DeptName
        {
            get { return _deptName; }
            set { _deptName = value; }
        }

        private string _deptPath;

        public string DeptPath
        {
            get { return _deptPath; }
            set { _deptPath = value; }
        }

        private string _roleID;

        public string RoleID
        {
            get { return _roleID; }
            set { _roleID = value; }
        }
        private string _roleName;

        public string RoleName
        {
            get { return _roleName; }
            set { _roleName = value; }
        }
        private bool _haveMutilRole;

        public bool HaveMutilRole
        {
            get { return _haveMutilRole; }
            set { _haveMutilRole = value; }
        }

        List<RoleAssign> _roles;

        public List<RoleAssign> Roles
        {
            get { return _roles; }
            set { _roles = value; }
        }


        private string _positionID;

        public string PositionID
        {
            get { return _positionID; }
            set { _positionID = value; }
        }

        private string _positionName;

        public string PositionName
        {
            get { return _positionName; }
            set { _positionName = value; }
        }

        private bool _haveMutilPosition;

        public bool HaveMutilPosition
        {
            get { return _haveMutilPosition; }
            set { _haveMutilPosition = value; }
        }

        List<PositionAssign> _positions;

        public List<PositionAssign> Positions
        {
            get { return _positions; }
            set { _positions = value; }
        }

        //private Dictionary<string, AuthOperate> _authOperates;

        //public Dictionary<string, AuthOperate> AuthOperates
        //{
        //    get
        //    {
        //        if (null == _authOperates)
        //        {
        //            lock (_lockObject)
        //            {
        //                if (null == _authOperates)
        //                {
        //                    _authOperates = new Dictionary<string, AuthOperate>();
        //                    var objs = from a in this.Roles select (from b in a.AuthOperates.Values select b);
        //                    foreach (AuthOperate o in objs)
        //                    {
        //                        _authOperates[o.OperateName] = o;
        //                    }
        //                    return _authOperates;
        //                }
        //                else
        //                {
        //                    return _authOperates;
        //                }
        //            }
        //        }
        //        else
        //        {
        //            return _authOperates;
        //        }
        //    }
        //}
    }

    public class RoleAssign
    {
        public RoleAssign()
        {
            _authOperates = new Dictionary<string, AuthOperate>();
            _authPages = new List<string>();
        }
        string _departmentID;

        public string DepartmentID
        {
            get { return _departmentID; }
            set { _departmentID = value; }
        }
        string _departmentName;

        public string DepartmentName
        {
            get { return _departmentName; }
            set { _departmentName = value; }
        }

        string _deptPath;

        public string DeptPath
        {
            get { return _deptPath; }
            set { _deptPath = value; }
        }

        string _roleId;

        public string RoleId
        {
            get { return _roleId; }
            set { _roleId = value; }
        }
        string _roleName;

        public string RoleName
        {
            get { return _roleName; }
            set { _roleName = value; }
        }

        string _positionID;

        public string PositionID
        {
            get { return _positionID; }
            set { _positionID = value; }
        }
        string _positionName;

        public string PositionName
        {
            get { return _positionName; }
            set { _positionName = value; }
        }

        Dictionary<string, AuthOperate> _authOperates;

        public Dictionary<string, AuthOperate> AuthOperates
        {
            get { return _authOperates; }
            set { _authOperates = value; }
        }

        private List<string> _authPages;

        public List<string> AuthPages
        {
            get { return _authPages; }
            set { _authPages = value; }
        }
    }

    public class PositionAssign
    {
        string _departmentID;

        public string DepartmentID
        {
            get { return _departmentID; }
            set { _departmentID = value; }
        }
        string _departmentName;

        public string DepartmentName
        {
            get { return _departmentName; }
            set { _departmentName = value; }
        }
        string _positionID;

        public string PositionID
        {
            get { return _positionID; }
            set { _positionID = value; }
        }
        string _positionName;

        public string PositionName
        {
            get { return _positionName; }
            set { _positionName = value; }
        }
    }

    public class AuthOperate
    {

        private string _operateID;

        public string OperateID
        {
            get { return _operateID; }
            set { _operateID = value; }
        }
        private short _deptRange;

        public short DeptRange
        {
            get { return _deptRange; }
            set { _deptRange = value; }
        }
        private string _operateName;

        public string OperateName
        {
            get { return _operateName; }
            set { _operateName = value; }
        }

        private string _operateNo;

        public string OperateNo
        {
            get { return _operateNo; }
            set { _operateNo = value; }
        }
    }
}
